--编写者：alt
--功能介绍：物品欄動畫特效
--使用方法：直接粘贴 需要修改对应逻辑

--物品欄動畫特效：icon_fx（寫法參考麥斯威爾禮帽）
local UIAnim = require "widgets/uianim"
AddClassPostConstruct("widgets/itemtile", function(self)
    if self.item then
        self.inst:ListenForEvent("imagechange",
            function(invitem)
                self.item:DoTaskInTime(0, function()
                    if self.item:HasTag("astesia_resonance_item") and self.item:HasTag("activity") then
                        if self.astesia_resonancefx == nil then
                            self.astesia_resonancefx = self.image:AddChild(UIAnim())
                            self.astesia_resonancefx:GetAnimState():SetBank("ast_understar")
                            self.astesia_resonancefx:GetAnimState():SetBuild("ast_items")
                            self.astesia_resonancefx:GetAnimState():PlayAnimation("icon_fx", true)
                            self.astesia_resonancefx:GetAnimState():SetTime(math.random() *
                                self.astesia_resonancefx:GetAnimState():GetCurrentAnimationTime())
                            self.astesia_resonancefx:SetScale(.5)
                            self.astesia_resonancefx:GetAnimState():AnimateWhilePaused(false)
                            self.astesia_resonancefx:SetClickable(false)
                        end
                    elseif self.astesia_resonancefx ~= nil then
                        self.astesia_resonancefx:Kill()
                        self.astesia_resonancefx = nil
                    end
                end)
            end, self.item)
    end
end)
